import Vue from 'vue';
import Vuex from 'vuex';
import router from '../router/index';
import OrderUser from './module/Order_user'

Vue.use(Vuex);

export const store = new Vuex.Store({
    state: {
        // 通用的token
        token: localStorage.getItem('token') || '',


        // 下面这些是用于面料下单门店界面的数据
        stooreCode: '',
        kuaidiID: '',
        addressType: '',
        address: '',
        phone: '',
        name: '',
        // 选中的门店对象
        store: null,
        radioStat3: '',
        radioStat4: '',
        // 选择的常用地址
        sdaa: null,

        // 下面这些是现货下单的数据
        stooreCode2: '',
        kuaidiID2: '',
        addressType2: '',
        address2: '',
        phone2: '',
        name2: '',
        // 选中的门店对象
        store2: null,
        radioStat32: '',
        radioStat42: '',
        // 选择的常用地址
        sdaa2: null,
    },
    mutations: {//动作事件
        loginIn(state, token) {//登录
            localStorage.setItem('token', token);
            state.token = token;
        },
        loginOut(state) {//退出
            localStorage.clear();
            state.token = '';
            router.push('/');
        },
    },
    actions: {//异步

    },
    getters: {
        isLogin: state => !!state.token,//监听token变化
    },
    modules: {
        OrderUser,//个订
    }
});

export default store